﻿$(function () {
    $('#btn').click(function () {
        var items = $('input[formItem]');
        var data = [];
        $.each(items, function (i, item) {
            data.push({ key: $(item).attr('name'), value: $(item).val() });
        });
        var dataString = JSON.stringify(data);
        var loading = showLoading();
        $.post('save', { values: dataString }, function (result) {
            if (result.success)
                $.dialog.succeedTips('保存成功！', function () { });
            else
                $.dialog.errorTips('保存失败！' + result.msg);
            loading.close();
        });
    });

    $('.btn_resettmpl').click(function () {
        var _t = $(this);
        editmsgtype = _t.data("msgtype");
        ResetWXTmplate();
    });
});

function ResetWXTmplate() {
    var loading = showLoading();
    $.post('ResetWXTmplate', {}, function (result) {
        loading.close();
        if (result.success) {
            $.dialog.succeedTips('初始微信消息模板成功！', function () { });
            window.location.reload();
        } else {
            $.dialog.errorTips('重置微信消息模板失败！' + result.msg);
        }
    });

}